
package ree9opdz . mcsn8yds ;

/**
 * Utitily for dealing with Hibernate.
 **/
public final class HibernateUtil
{
    /**
     * Hides the no-args constructor.
     **/
    private HibernateUtil ( )
    {
	super ( ) ;
    }

    /**
     * The Singleton SessionFactory.
     **/
    private static final org . hibernate . SessionFactory
	SESSIONFACTORY ;

    static
    {
        try
	    {
		// Create the SessionFactory from hibernate.cfg.xml
		SESSIONFACTORY =
		    new org . hibernate . cfg . Configuration ( ) .
		    configure ( ) . buildSessionFactory ( ) ;
	    }
	catch ( Throwable ex )
	    {
		// Make sure you log the exception, as it might be swallowed
		System.err.println
		    ( "Initial SessionFactory creation failed." + ex ) ;
		throw ( new ExceptionInInitializerError ( ex ) ) ;
	    }
    }

    /**
     * Return the singleton session factory.
     *
     * @return the singleton session factory
     **/
    public static org . hibernate . SessionFactory getSessionFactory ( )
    {
        return SESSIONFACTORY ;
    }
}
